/// <reference types="node" />
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd());
  return {
    plugins: [vue()],
    base: "/",
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'), // 新增
      },
    },
    build: {
      outDir:
        mode === "production"
          ? "dist"
          : mode === "test"
          ? "dist-test"
          : "dist-dev",
    },
    define: {
      __APP_ENV__: JSON.stringify(env.VITE_APP_ENV),
    },
    server: {
      port: 9999, // 启动端口
      open: true, // 自动打开浏览器
    },
  };
});
